package chapter10;

public class MyInteger {

	private int value;
	
	public MyInteger(){
		this(0);
	}
	
	public MyInteger(int value) {
		this.value = value;
	}
	
	public int getValue(){
		return this.value;
	}
	
	public boolean isEven(){
		return this.value % 2 == 0? true: false;
	}
	
	public boolean isEven(int value){
		return value % 2 == 0? true: false;
	}
	
	public boolean isEven(MyInteger intObj){
		return intObj.getValue() % 2 == 0? true: false;
	}
	
	public boolean isOdd(){
		return this.value % 2 != 0? true: false;
	}
	
	public boolean isOdd(int value){
		return value % 2 != 0? true: false;
	}
	
	public boolean isOdd(MyInteger intObj){
		return intObj.getValue() % 2 != 0? true: false;
	}

	public boolean isPrime(){
		if (value == 0 || value == 1 )
			return false;
		for (int i = 1; i < Math.sqrt(value); i++){
			if(value % i == 0 && i != 1)
				return false;
		}
		return true;
	}
	
	public boolean isPrime(int value){
		if (value == 0 || value == 1)
			return false;
		for (int i = 1; i < Math.sqrt(value); i++){
			if(value % i == 0 && i != 1)
				return false;
		}
		return true;
	}
	
	public boolean isPrime(MyInteger intObj){
		int value = intObj.getValue();
		if (value == 0 || value == 1)
			return false;
		for (int i = 1; i < Math.sqrt(value); i++){
			if(value % i == 0 && i != 1)
				return false;
		}
		return true;
	}
	
	public boolean equals(int value){
		return this.value == value? true: false;
	}
	
	public boolean equals(MyInteger intObj){
		int value = intObj.getValue();
		return this.value == value? true: false;
	}
	
	public static int[] parseInt(char[] charArray){
		int[] intArray = new int[charArray.length];
		for (int i =0; i < charArray.length; i++){
			if (charArray[i] >= '0' && charArray[i] <= '9'){
				intArray[i] = charArray[i] - '0';
			}
		}
		return intArray;
	}
	
	public static int[] parseInt(String charArray){
		int[] intArray = new int[charArray.length()];
		for (int i =0; i < charArray.length(); i++){
			if (charArray.charAt(i) >= '0' && charArray.charAt(i) <= '9'){
				intArray[i] = charArray.charAt(i) - '0';
			}
		}
		return intArray;
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}
